package io.arukas;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine;

/**
 * Created by IntelliJ IDEA. <br/>
 *
 * @author 牛玉贤 <br/>
 * @date 08/06/2020 09:41 <br/>
 * @email ncc0706@gmail.com <br/>
 */
@RestController
public class IMEndpoint {

    @Autowired
    private SpringTemplateEngine xmlTemplateEngine;

    @GetMapping("welcome")
    public String welcome() throws JsonProcessingException {
        //创建邮件正文
        Context context = new Context();
        context.setVariable("inf_id", "PO018");
        context.setVariable("body", "Hello");
        String content = xmlTemplateEngine.process("IM", context);
        return content;
    }


}
